import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'
import CategoryEdit from '../views/CategoryEdit.vue'
import CategoryList from '../views/CategoryList.vue'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'Main',
    component: Main,
    children: [
      {
        path: 'categoriesedit',
        component: CategoryEdit
      },
      {
        path: 'categorieslist',
        component: CategoryList
      },
      {
        path: 'categoryedit/:id',
        component: CategoryEdit,
        props: true
      },
    ]
  },

]

const router = new VueRouter({
  routes
})

export default router
